# 设置类
class Oly:
    def __init__(self, country, jin, yin, tong):
        self.country = country
        self.jin = jin
        self.yin = yin
        self.tong = tong

    def add_jiangpai(self, add_jin, add_yin, add_tong):
        self.jin = self.jin + add_jin
        self.yin = self.yin + add_yin
        self.tong = self.tong + add_tong

    def zong_he(self):
        return self.jin + self.yin + self.tong

    def __str__(self):
        return (f'{self.country}金牌{self.jin}枚，银牌{self.yin}枚，铜牌{self.tong}枚，奖牌总计{self.zong_he()}枚')

# 录入数据
zhong_guo = Oly('中国', 2, 2, 3)
mei_guo = Oly('美国', 2, 2, 4)
e_guo = Oly('俄罗斯', 3, 1, 1)
ying_guo = Oly('英国', 0, 2, 3)
fa_guo = Oly('法', 0, 2, 2)
# 显示所录入的数据
print(zhong_guo)
print(mei_guo)
print(e_guo)
print(ying_guo)
print(fa_guo)
print('\n')
# 部分国家奖牌数量变化
print('中国新夺得3枚金牌，1枚铜牌')
zhong_guo.add_jiangpai(3, 1, 0)
print('美国新夺得3枚银牌，1枚铜牌')
mei_guo.add_jiangpai(0, 3, 1)
print('俄罗斯新夺得1枚金牌，1枚银牌，1枚铜牌')
e_guo.add_jiangpai(1, 1, 1)
print('\n')
jiang_pai_list = [zhong_guo, mei_guo, e_guo, ying_guo, fa_guo]
jin_pai_paixu = sorted(jiang_pai_list, key=lambda a: a.jin, reverse=True)
zong_shu_paixu = sorted(jiang_pai_list, key=lambda a: a.zong_he(), reverse=True)
# 奖牌数量变化后分别按金牌数与奖牌总数进行排序显示
print('按金牌数量排序：')
for i in jin_pai_paixu:
    print(i)
print('\n')
print('按总奖牌数量排序')
for i in zong_shu_paixu:
    print(i)
